<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.2.1">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/dute_favicon_32x32.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/dute_favicon_16x16.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">
  <link rel="manifest" href="/images/manifest.json">
  <meta name="msapplication-config" content="/images/browserconfig.xml">
  <meta http-equiv="Cache-Control" content="no-transform">
  <meta http-equiv="Cache-Control" content="no-siteapp">
  <meta name="google-site-verification" content="mpI5dkydstZXl6UcDCppqktXK0bbvqdZ6LkZ3KNk4Iw">
  <meta name="baidu-site-verification" content="code-a1LksZX2Ds">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">
  <link rel="stylesheet" href="//cdn.jsdelivr.net/gh/fancyapps/fancybox@3/dist/jquery.fancybox.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"whitestore.top","root":"/","scheme":"Gemini","version":"7.8.0","exturl":true,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":true,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":true,"scrollpercent":true},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":true,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="JDK1.8 日期类">
<meta property="og:type" content="article">
<meta property="og:title" content="JDK1.8 日期类">
<meta property="og:url" content="https://whitestore.top/2020/07/26/note7/index.html">
<meta property="og:site_name" content="爱看书的阿东">
<meta property="og:description" content="JDK1.8 日期类">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2020-07-26T11:57:44.000Z">
<meta property="article:modified_time" content="2023-07-16T06:28:09.223Z">
<meta property="article:author" content="阿东">
<meta property="article:tag" content="JDK1.8 日期类">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="https://whitestore.top/2020/07/26/note7/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>JDK1.8 日期类 | 爱看书的阿东</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

<link rel="alternate" href="/atom.xml" title="爱看书的阿东" type="application/atom+xml">
</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">爱看书的阿东</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">赐他一块白色石头，石头上写着新名</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-fw fa-th"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
        <li class="menu-item menu-item-sitemap">

    <a href="/sitemap.xml" rel="section"><i class="fa fa-fw fa-sitemap"></i>站点地图</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    

  <span class="exturl github-corner" data-url="aHR0cHM6Ly9naXRodWIuY29tL2xhenlUaW1lcw==" title="Follow me on GitHub" aria-label="Follow me on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></span>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://whitestore.top/2020/07/26/note7/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="阿东">
      <meta itemprop="description" content="随遇而安">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="爱看书的阿东">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          JDK1.8 日期类
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2020-07-26 19:57:44" itemprop="dateCreated datePublished" datetime="2020-07-26T19:57:44+08:00">2020-07-26</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2023-07-16 14:28:09" itemprop="dateModified" datetime="2023-07-16T14:28:09+08:00">2023-07-16</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Java/" itemprop="url" rel="index"><span itemprop="name">Java</span></a>
                </span>
            </span>

          
            <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv" style="display: none;">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span id="busuanzi_value_page_pv"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2020/07/26/note7/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2020/07/26/note7/" itemprop="commentCount"></span>
    </a>
  </span>
  
  <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="fa fa-file-word-o"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>8.6k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="fa fa-clock-o"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>8 分钟</span>
            </span>
            <div class="post-description">JDK1.8 日期类</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h1 id="参考博客"><a href="#参考博客" class="headerlink" title="参考博客"></a><span class="exturl" data-url="aHR0cHM6Ly9sdzkwMDkyNS5naXRodWIuaW8vamF2YS9qYXZhOC1uZXd0aW1lLWFwaS5odG1s" title="https://lw900925.github.io/java/java8-newtime-api.html">参考博客<i class="fa fa-external-link"></i></span></h1><a id="more"></a>

<h1 id="获取指定时间的上一个工作日和下一个工作日（无判断节假日，调休）"><a href="#获取指定时间的上一个工作日和下一个工作日（无判断节假日，调休）" class="headerlink" title="获取指定时间的上一个工作日和下一个工作日（无判断节假日，调休）"></a>获取指定时间的上一个工作日和下一个工作日（无判断节假日，调休）</h1><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;**</span><br><span class="line">     * 获取指定时间的上一个工作日</span><br><span class="line">     *</span><br><span class="line">     * @param time           指定时间</span><br><span class="line">     * @param formattPattern 格式化参数</span><br><span class="line">     * @return</span><br><span class="line">     *&#x2F;</span><br><span class="line">    public static String getPreWorkDay(String time, String formattPattern) &#123;</span><br><span class="line">        DateTimeFormatter dateTimeFormatter &#x3D; generateDefualtPattern(formattPattern);</span><br><span class="line">        LocalDateTime compareTime1 &#x3D; LocalDateTime.parse(time, dateTimeFormatter);</span><br><span class="line">        compareTime1 &#x3D; compareTime1.with(temporal -&gt; &#123;</span><br><span class="line">            &#x2F;&#x2F; 当前日期</span><br><span class="line">            DayOfWeek dayOfWeek &#x3D; DayOfWeek.of(temporal.get(ChronoField.DAY_OF_WEEK));</span><br><span class="line">            &#x2F;&#x2F; 正常情况下，每次减去一天</span><br><span class="line">            int dayToMinu &#x3D; 1;</span><br><span class="line">            &#x2F;&#x2F; 如果是周日，减去2天</span><br><span class="line">            if (dayOfWeek &#x3D;&#x3D; DayOfWeek.SUNDAY) &#123;</span><br><span class="line">                dayToMinu &#x3D; 2;</span><br><span class="line">            &#125;</span><br><span class="line">            &#x2F;&#x2F; 如果是周六，减去一天</span><br><span class="line">            if (dayOfWeek &#x3D;&#x3D; DayOfWeek.SATURDAY) &#123;</span><br><span class="line">                dayToMinu &#x3D; 1;</span><br><span class="line">            &#125;</span><br><span class="line">            return temporal.minus(dayToMinu, ChronoUnit.DAYS);</span><br><span class="line">        &#125;);</span><br><span class="line">        return compareTime1.format(dateTimeFormatter);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    &#x2F;**</span><br><span class="line">     * 获取指定时间的下一个工作日</span><br><span class="line">     *</span><br><span class="line">     * @param time           指定时间</span><br><span class="line">     * @param formattPattern 格式参数</span><br><span class="line">     * @return</span><br><span class="line">     *&#x2F;</span><br><span class="line">    public static String getNextWorkDay(String time, String formattPattern) &#123;</span><br><span class="line">        DateTimeFormatter dateTimeFormatter &#x3D; generateDefualtPattern(formattPattern);</span><br><span class="line">        LocalDateTime compareTime1 &#x3D; LocalDateTime.parse(time, dateTimeFormatter);</span><br><span class="line">        compareTime1 &#x3D; compareTime1.with(temporal -&gt; &#123;</span><br><span class="line">            &#x2F;&#x2F; 当前日期</span><br><span class="line">            DayOfWeek dayOfWeek &#x3D; DayOfWeek.of(temporal.get(ChronoField.DAY_OF_WEEK));</span><br><span class="line">            &#x2F;&#x2F; 正常情况下，每次增加一天</span><br><span class="line">            int dayToAdd &#x3D; 1;</span><br><span class="line">            &#x2F;&#x2F; 如果是星期五，增加三天</span><br><span class="line">            if (dayOfWeek &#x3D;&#x3D; DayOfWeek.FRIDAY) &#123;</span><br><span class="line">                dayToAdd &#x3D; 3;</span><br><span class="line">            &#125;</span><br><span class="line">            &#x2F;&#x2F; 如果是星期六，增加两天</span><br><span class="line">            if (dayOfWeek &#x3D;&#x3D; DayOfWeek.SATURDAY) &#123;</span><br><span class="line">                dayToAdd &#x3D; 2;</span><br><span class="line">            &#125;</span><br><span class="line">            return temporal.plus(dayToAdd, ChronoUnit.DAYS);</span><br><span class="line">        &#125;);</span><br><span class="line">        return compareTime1.format(dateTimeFormatter);</span><br><span class="line">    &#125;</span><br></pre></td></tr></table></figure>

<h1 id="LocalDate、LocalTime、LocalDateTime-三者区别"><a href="#LocalDate、LocalTime、LocalDateTime-三者区别" class="headerlink" title="LocalDate、LocalTime、LocalDateTime 三者区别"></a>LocalDate、LocalTime、LocalDateTime 三者区别</h1><p><code>LocalDate</code>：类表示一个具体的日期，但不包含具体时间，也不包含时区信息。可以通过<code>LocalDate</code>的静态方法<code>of()</code>创建一个实例，<code>LocalDate</code>也包含一些方法用来获取年份，月份，天，星期几等</p>
<p><code>LocalTime</code>：和<code>LocalDate</code>类似，区别在于包含具体时间</p>
<p><code>LocalDateTime</code>：<code>LocalDateTime</code>类是<code>LocalDate</code>和<code>LocalTime</code>的结合体，可以通过<code>of()</code>方法直接创建，也可以调用<code>LocalDate</code>的<code>atTime()</code>方法或<code>LocalTime</code>的<code>atDate()</code>方法将<code>LocalDate</code>或<code>LocalTime</code>合并成一个<code>LocalDateTime</code>：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">LocalDateTime ldt1 &#x3D; LocalDateTime.of(2017, Month.JANUARY, 4, 17, 23, 52);</span><br><span class="line"></span><br><span class="line">LocalDate localDate &#x3D; LocalDate.of(2017, Month.JANUARY, 4);</span><br><span class="line">LocalTime localTime &#x3D; LocalTime.of(17, 23, 52);</span><br><span class="line">LocalDateTime ldt2 &#x3D; localDate.atTime(localTime);</span><br></pre></td></tr></table></figure>

<h2 id="时间戳"><a href="#时间戳" class="headerlink" title="时间戳"></a>时间戳</h2><h3 id="Instant"><a href="#Instant" class="headerlink" title="Instant"></a><code>Instant</code></h3><p><code>Instant</code>用于表示一个时间戳，它与我们常使用的<code>System.currentTimeMillis()</code>有些类似，不过<code>Instant</code>可以精确到纳秒（Nano-Second）</p>
<blockquote>
<p>注意： 内部使用了两个常量，<code>seconds</code>表示从1970-01-01 00:00:00开始到现在的秒数，<code>nanos</code>表示纳秒部分（<code>nanos</code>的值不会超过<code>999,999,999</code>）</p>
</blockquote>
<h3 id="Duration"><a href="#Duration" class="headerlink" title="Duration"></a><code>Duration</code></h3><p><code>Duration</code>的内部实现与<code>Instant</code>类似，也是包含两部分：<code>seconds</code>表示秒，<code>nanos</code>表示纳秒。两者的区别是<code>Instant</code>用于表示一个时间戳（或者说是一个时间点），而<code>Duration</code>表示一个时间段</p>
<h3 id="Period"><a href="#Period" class="headerlink" title="Period"></a><code>Period</code></h3><p><code>Period</code>在概念上和<code>Duration</code>类似，区别在于<code>Period</code>是以年月日来衡量一个时间段，比如2年3个月6天：</p>
<h1 id="问题1：错误"><a href="#问题1：错误" class="headerlink" title="问题1：错误"></a>问题1：错误</h1><p>报错</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Text &#39;2020-09-01&#39; could not be parsed: Unable to obtain LocalDateTime from TemporalAccessor: &#123;&#125;,ISO resolved to 2020-09-01 of type java.time.format.Parsed</span><br></pre></td></tr></table></figure>

<p>##　解决办法</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">https:&#x2F;&#x2F;blog.csdn.net&#x2F;qq_28988969&#x2F;article&#x2F;details&#x2F;90610580</span><br></pre></td></tr></table></figure>

<h1 id="问题2：-学习jdk1-8-的时间"><a href="#问题2：-学习jdk1-8-的时间" class="headerlink" title="问题2： 学习jdk1.8 的时间"></a>问题2： 学习jdk1.8 的时间</h1><p><span class="exturl" data-url="aHR0cHM6Ly93d3cuamlhbnNodS5jb20vcC9mNGFiZTFlMzhlMDk=" title="https://www.jianshu.com/p/f4abe1e38e09">https://www.jianshu.com/p/f4abe1e38e09<i class="fa fa-external-link"></i></span></p>
<h1 id="问题3-关于js端口的时间格式化问题"><a href="#问题3-关于js端口的时间格式化问题" class="headerlink" title="问题3: 关于js端口的时间格式化问题"></a>问题3: 关于js端口的时间格式化问题</h1><p>问题： new Date() 方法如何当前设备的时间是错的会出现问题</p>
<h1 id="问题4：-时间比较的问题"><a href="#问题4：-时间比较的问题" class="headerlink" title="问题4： 时间比较的问题"></a>问题4： 时间比较的问题</h1><p>比较的常用方法</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;&#x2F;格式化日期</span><br><span class="line">var format &#x3D; function (time, format) &#123;</span><br><span class="line">    var t &#x3D; new Date(time);</span><br><span class="line">    var tf &#x3D; function (i) &#123;</span><br><span class="line">        return (i &lt; 10 ? &#39;0&#39; : &#39;&#39;) + i</span><br><span class="line">    &#125;;</span><br><span class="line">    return format.replace(&#x2F;yyyy|MM|dd|HH|mm|ss&#x2F;g, function (a) &#123;</span><br><span class="line">        switch (a) &#123;</span><br><span class="line">            case &#39;yyyy&#39;:</span><br><span class="line">                return tf(t.getFullYear());</span><br><span class="line">                break;</span><br><span class="line">            case &#39;MM&#39;:</span><br><span class="line">                return tf(t.getMonth() + 1);</span><br><span class="line">                break;</span><br><span class="line">            case &#39;mm&#39;:</span><br><span class="line">                return tf(t.getMinutes());</span><br><span class="line">                break;</span><br><span class="line">            case &#39;dd&#39;:</span><br><span class="line">                return tf(t.getDate());</span><br><span class="line">                break;</span><br><span class="line">            case &#39;HH&#39;:</span><br><span class="line">                return tf(t.getHours());</span><br><span class="line">                break;</span><br><span class="line">            case &#39;ss&#39;:</span><br><span class="line">                return tf(t.getSeconds());</span><br><span class="line">                break;</span><br><span class="line">        &#125;</span><br><span class="line">        ;</span><br><span class="line">    &#125;);</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>

<h1 id="问题5：调用format出现Text-39-2020-06-02-15-22-22-39-could-not-be-parsed-unparsed-text-found-at-index-10"><a href="#问题5：调用format出现Text-39-2020-06-02-15-22-22-39-could-not-be-parsed-unparsed-text-found-at-index-10" class="headerlink" title="问题5：调用format出现Text &#39;2020-06-02 15:22:22&#39; could not be parsed, unparsed text found at index 10"></a>问题5：调用format出现<code>Text &#39;2020-06-02 15:22:22&#39; could not be parsed, unparsed text found at index 10</code></h1><p>问题原因：使用错误的格式去格式字符串，比如<code>yyyy-MM-dd</code> 格式化 <code>2020-05-12 12:15:33</code> 这种格式就会出现溢出 解决办法：使用正确的格式即可</p>
<p>学习参考</p>
<p><span class="exturl" data-url="aHR0cHM6Ly9sdzkwMDkyNS5naXRodWIuaW8vamF2YS9qYXZhOC1uZXd0aW1lLWFwaS5odG1s" title="https://lw900925.github.io/java/java8-newtime-api.html">https://lw900925.github.io/java/java8-newtime-api.html<i class="fa fa-external-link"></i></span></p>
<p>关于格式化的问题</p>
<ol>
<li>对于上面几个问题的根本解决办法 原因：因为localdatetime 在进行格式化的时候如何case没有找到对应的格式，那么就会出现类似<code>unsupport</code>方法</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;**</span><br><span class="line">     * 生成默认的格式器</span><br><span class="line">     *</span><br><span class="line">     * @param timeFormat 指定格式</span><br><span class="line">     * @return</span><br><span class="line">     *&#x2F;</span><br><span class="line">    private static DateTimeFormatter generateDefualtPattern(String timeFormat) &#123;</span><br><span class="line">        return new DateTimeFormatterBuilder().appendPattern(timeFormat)</span><br><span class="line">                .parseDefaulting(ChronoField.HOUR_OF_DAY, 1)</span><br><span class="line">                .parseDefaulting(ChronoField.MINUTE_OF_HOUR, 1)</span><br><span class="line">                .parseDefaulting(ChronoField.SECOND_OF_MINUTE, 0)</span><br><span class="line">                .toFormatter(Locale.CHINA);</span><br><span class="line">    &#125;</span><br></pre></td></tr></table></figure>

<ol>
<li><h1 id="问题6：关于DateTimeParseException"><a href="#问题6：关于DateTimeParseException" class="headerlink" title="问题6：关于DateTimeParseException"></a>问题6：关于DateTimeParseException</h1></li>
</ol>
<p>参考了下面到异常日志，根本的原因是<code>DateTimeFormatter</code>格式化没有<code>HH</code>选项，需要根据问题5的解决方式进行处理</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">java.time.format.DateTimeParseException: Text &#39;2017-02-02 08:59:12&#39; could not be parsed: Unable to obtain LocalDateTime from TemporalAccessor: &#123;MinuteOfHour&#x3D;59, NanoOfSecond&#x3D;0, SecondOfMinute&#x3D;12, MicroOfSecond&#x3D;0, MilliOfSecond&#x3D;0, HourOfAmPm&#x3D;8&#125;,ISO resolved to 2017-02-02 of type java.time.format.Parsed</span><br></pre></td></tr></table></figure>

<p>StackFlow地址：<span class="exturl" data-url="aHR0cHM6Ly9zdGFja292ZXJmbG93LmNvbS9xdWVzdGlvbnMvNDM3MzI3NTEvZGF0ZXRpbWVwYXJzZWV4Y2VwdGlvbi10ZXh0LWNvdWxkLW5vdC1iZS1wYXJzZWQtdW5hYmxlLXRvLW9idGFpbi1sb2NhbGRhdGV0aW1l" title="https://stackoverflow.com/questions/43732751/datetimeparseexception-text-could-not-be-parsed-unable-to-obtain-localdatetime">DateTimeParseException: Text could not be parsed: Unable to obtain LocalDateTime from TemporalAccessor<i class="fa fa-external-link"></i></span></p>
<p>StackFlow地址：<span class="exturl" data-url="aHR0cHM6Ly9zdGFja292ZXJmbG93LmNvbS9xdWVzdGlvbnMvNDM3MzI3NTEvZGF0ZXRpbWVwYXJzZWV4Y2VwdGlvbi10ZXh0LWNvdWxkLW5vdC1iZS1wYXJzZWQtdW5hYmxlLXRvLW9idGFpbi1sb2NhbGRhdGV0aW1lP3JxPTE=" title="https://stackoverflow.com/questions/43732751/datetimeparseexception-text-could-not-be-parsed-unable-to-obtain-localdatetime?rq=1">StackFlow无法解析文本：无法从TemporalAccessor获取LocalDateTime<i class="fa fa-external-link"></i></span></p>
<p>StackFlow地址：<span class="exturl" data-url="aHR0cHM6Ly9zdGFja292ZXJmbG93LmNvbS9xdWVzdGlvbnMvMjc0NTQwMjUvdW5hYmxlLXRvLW9idGFpbi1sb2NhbGRhdGV0aW1lLWZyb20tdGVtcG9yYWxhY2Nlc3Nvci13aGVuLXBhcnNpbmctbG9jYWxkYXRldGltZQ==" title="https://stackoverflow.com/questions/27454025/unable-to-obtain-localdatetime-from-temporalaccessor-when-parsing-localdatetime">解析LocalDateTime（Java 8）时，无法从TemporalAccessor获取LocalDateTime<i class="fa fa-external-link"></i></span></p>
<h1 id="其他问题收集"><a href="#其他问题收集" class="headerlink" title="其他问题收集"></a>其他问题收集</h1><h2 id="关于LocalDate-class的一个坑"><a href="#关于LocalDate-class的一个坑" class="headerlink" title="关于LocalDate.class的一个坑"></a>关于LocalDate.class的一个坑</h2><p><span class="exturl" data-url="aHR0cHM6Ly9zdGFja292ZXJmbG93LmNvbS9xdWVzdGlvbnMvMjMwNjkzNzAvZm9ybWF0LWEtZGF0ZS11c2luZy10aGUtbmV3LWRhdGUtdGltZS1hcGkvMjMwNjk0MDg=" title="https://stackoverflow.com/questions/23069370/format-a-date-using-the-new-date-time-api/23069408">关于LocalDate一些源码分析<i class="fa fa-external-link"></i></span></p>
<p>直接上源代码</p>
<ol>
<li><code>LocalDate</code>仅代表一个日期，而不代表DateTime。因此，在格式化时，“ HH：mm：ss”是毫无意义的</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">private int get0(TemporalField field) &#123;</span><br><span class="line">        switch ((ChronoField) field) &#123;</span><br><span class="line">            case DAY_OF_WEEK: return getDayOfWeek().getValue();</span><br><span class="line">            case ALIGNED_DAY_OF_WEEK_IN_MONTH: return ((day - 1) % 7) + 1;</span><br><span class="line">            case ALIGNED_DAY_OF_WEEK_IN_YEAR: return ((getDayOfYear() - 1) % 7) + 1;</span><br><span class="line">            case DAY_OF_MONTH: return day;</span><br><span class="line">            case DAY_OF_YEAR: return getDayOfYear();</span><br><span class="line">            case EPOCH_DAY: throw new UnsupportedTemporalTypeException(&quot;Invalid field &#39;EpochDay&#39; for get() method, use getLong() instead&quot;);</span><br><span class="line">            case ALIGNED_WEEK_OF_MONTH: return ((day - 1) &#x2F; 7) + 1;</span><br><span class="line">            case ALIGNED_WEEK_OF_YEAR: return ((getDayOfYear() - 1) &#x2F; 7) + 1;</span><br><span class="line">            case MONTH_OF_YEAR: return month;</span><br><span class="line">            case PROLEPTIC_MONTH: throw new UnsupportedTemporalTypeException(&quot;Invalid field &#39;ProlepticMonth&#39; for get() method, use getLong() instead&quot;);</span><br><span class="line">            case YEAR_OF_ERA: return (year &gt;&#x3D; 1 ? year : 1 - year);</span><br><span class="line">            case YEAR: return year;</span><br><span class="line">            case ERA: return (year &gt;&#x3D; 1 ? 1 : 0);</span><br><span class="line">        &#125;</span><br><span class="line">        throw new UnsupportedTemporalTypeException(&quot;Unsupported field: &quot; + field);</span><br><span class="line">    &#125;</span><br></pre></td></tr></table></figure>

<h2 id="格式化问题"><a href="#格式化问题" class="headerlink" title="格式化问题:"></a>格式化问题:</h2><p>调用DateFomatter 有可能的报错，基本是由于使用错误到格式或者使用错误的时间类</p>
<p><span class="exturl" data-url="aHR0cHM6Ly9zdGFja292ZXJmbG93LmNvbS9xdWVzdGlvbnMvMzkwMzM1MjUvZXJyb3ItamF2YS10aW1lLWZvcm1hdC1kYXRldGltZXBhcnNlZXhjZXB0aW9uLWNvdWxkLW5vdC1iZS1wYXJzZWQtdW5wYXJzZWQtdGV4" title="https://stackoverflow.com/questions/39033525/error-java-time-format-datetimeparseexception-could-not-be-parsed-unparsed-tex">Error java.time.format.DateTimeParseException: could not be parsed, unparsed text found at index 10<i class="fa fa-external-link"></i></span></p>
<h1 id="侠说java8-LocalDateTime等时间使用手册（全）"><a href="#侠说java8-LocalDateTime等时间使用手册（全）" class="headerlink" title="侠说java8-LocalDateTime等时间使用手册（全）"></a>侠说java8-LocalDateTime等时间使用手册（全）</h1><p>侠说java8-LocalDateTime等时间使用手册（全），先mark后看 学习分享Java容器服务器：<span class="exturl" data-url="aHR0cHM6Ly9haWppc2h1LmNvbS9hLzEwNjAwMDAwMDAwODc3OTM=" title="https://aijishu.com/a/1060000000087793">https://aijishu.com/a/1060000000087793<i class="fa fa-external-link"></i></span></p>
<h1 id="源码个人解读"><a href="#源码个人解读" class="headerlink" title="源码个人解读"></a>源码个人解读</h1><h2 id="TemporalAccessor"><a href="#TemporalAccessor" class="headerlink" title="TemporalAccessor"></a>TemporalAccessor</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">java.time.temporal.TemporalAccessor</span><br></pre></td></tr></table></figure>

<p>翻译:</p>
<blockquote>
<p>框架级别的接口定义对时间对象（例如日期，时间，偏移量或这些的某种组合）的只读访问。 这是日期，时间和偏移对象的基本接口类型。它由可以提供信息作为字段或查询的那些类实现。 大多数日期和时间信息可以表示为数字。使用TemporalField对它们进行建模，并使用长号保留数字以处理较大的值。年，月和月日是字段的简单示例，但它们还包括即时数和偏移量。有关标准字段集，请参见ChronoField。 日期/时间信息不能用数字表示两个日期/时间信息。可以使用TemporalQuery上定义的静态方法通过查询来访问它们。 子接口Temporal将这个定义扩展到一个还支持对更完整的临时对象进行调整和操纵的定义。 该接口是框架级别的接口，不应在应用程序代码中广泛使用。相反，应用程序应创建并传递具体类型的实例，例如LocalDate。造成这种情况的原因很多，部分原因是该接口的实现可能在ISO以外的日历系统中。请参阅java.time.chrono.ChronoLocalDate以获得有关该问题的更完整讨论。</p>
</blockquote>
<h3 id="接口方法：isSupported"><a href="#接口方法：isSupported" class="headerlink" title="接口方法：isSupported()"></a>接口方法：isSupported()</h3><p>方法签名：<code>boolean isSupported(TemporalField field);</code></p>
<blockquote>
<p>检查是否支持指定的字段。 这检查是否可以查询指定字段的日期时间。 如果为false，则调用range和get方法将引发异常。</p>
<p>参数： field –要检查的字段，null返回false 返回值： 如果可以查询该日期时间，则为true，否则为false implSpec： 实现必须检查并处理ChronoField中定义的所有字段。 如果支持该字段，则必须返回true，否则必须返回false。 如果该字段不是ChronoField，则通过调用TemporalField.isSupportedBy（TemporalAccessor）并将其作为参数来获取此方法的结果。 实现必须确保在调用此只读方法时，不会更改任何可观察的状态。</p>
</blockquote>
<h3 id="接口方法：range-TemporalField-field"><a href="#接口方法：range-TemporalField-field" class="headerlink" title="接口方法：range(TemporalField field)"></a>接口方法：range(TemporalField field)</h3><p>方法签名：<code>ValueRange range(TemporalField field)</code></p>
<blockquote>
<p>获取指定字段的有效值范围。 所有字段都可以表示为长整数。此方法返回一个对象，该对象描述该值的有效范围。该时间对象的值用于增强返回范围的准确性。如果日期时间不能返回范围，则由于该字段不受支持或出于其他原因，将引发异常。 请注意，结果仅描述了最小和最大有效值，重要的是不要过多地阅读这些值。例如，在该范围内可能存在对该字段无效的值。</p>
<p>参数： field –查询范围的字段，不为null 返回值： 该字段的有效值范围，不为null 抛出： DateTimeException-如果无法获取该字段的范围 UnsupportedTemporalTypeException-如果不支持该字段 implSpec： 实现必须检查并处理ChronoField中定义的所有字段。如果支持该字段，则必须返回该字段的范围。如果不受支持，则必须引发UnsupportedTemporalTypeException。 如果该字段不是ChronoField，则通过调用TemporalField.rangeRefinedBy（TemporalAccessorl）并将其作为参数来获取此方法的结果。 实现必须确保在调用此只读方法时，不会更改任何可观察的状态。 默认实现必须与以下代码等效： if（ChronoField的instance字段）{if（isSupported（field））{return field.range（）; }抛出新的UnsupportedTemporalTypeException（“不支持的字段：” +字段）； } return field.rangeRefinedBy（this）;</p>
</blockquote>
<h3 id="接口方法：int-get-TemporalField-field"><a href="#接口方法：int-get-TemporalField-field" class="headerlink" title="接口方法：int get(TemporalField field)"></a>接口方法：int get(TemporalField field)</h3><blockquote>
<p>以int形式获取指定字段的值。 这将查询日期时间以获取指定字段的值。返回的值将始终在该字段的值的有效范围内。如果日期时间由于该字段不受支持或出于某些其他原因而无法返回该值，则将引发异常。</p>
<p>参数： field-要获取的字段，不为null 返回值： 有效值范围内的字段值 抛出： DateTimeException-如果无法获取该字段的值或该值超出该字段的有效值范围 UnsupportedTemporalTypeException-如果不支持该字段或值的范围超出int ArithmeticException-如果发生数字溢出 implSpec： 实现必须检查并处理ChronoField中定义的所有字段。如果该字段受支持并且具有int范围，则必须返回该字段的值。如果不受支持，则必须引发UnsupportedTemporalTypeException。 如果该字段不是ChronoField，则通过调用TemporalField.getFrom（TemporalAccessor）并将其作为参数来获取此方法的结果。 实现必须确保在调用此只读方法时，不会更改任何可观察的状态。 默认实现必须与以下代码等效： if（range（field）.isIntValue（））{返回range（field）.checkValidIntValue（getLong（field），field）; }抛出新的UnsupportedTemporalTypeException（“无效字段” +字段+“ +对于get（）方法，请使用getLong（）代替”）；</p>
</blockquote>
<h3 id="接口方法：default-R-query-TemporalQuery-query"><a href="#接口方法：default-R-query-TemporalQuery-query" class="headerlink" title="接口方法：default  R query(TemporalQuery query)"></a>接口方法：default <R> R query(TemporalQuery<R> query)</h3><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/kity@2.0.4/dist/kity.min.js"></script><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/kityminder-core@1.4.50/dist/kityminder.core.min.js"></script><script defer="true" type="text/javascript" src="https://cdn.jsdelivr.net/npm/hexo-simple-mindmap@0.2.0/dist/mindmap.min.js"></script><link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/hexo-simple-mindmap@0.2.0/dist/mindmap.min.css">
    </div>

    
    
    
        

<div>
<ul class="post-copyright">
  <li class="post-copyright-author">
    <strong>本文作者： </strong>lazytime
  </li>
  <li class="post-copyright-link">
    <strong>本文链接：</strong>
    <a href="https://whitestore.top/2020/07/26/note7/" title="JDK1.8 日期类">https://whitestore.top/2020/07/26/note7/</a>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>本博客所有文章除特别声明外，均采用 <span class="exturl" data-url="aHR0cHM6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL2xpY2Vuc2VzL2J5LW5jLzQuMC96aC1DTg=="><i class="fa fa-fw fa-creative-commons"></i>BY-NC</span> 许可协议。转载请注明出处！
  </li>
</ul>
</div>


      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/Java/" rel="tag"># Java</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2020/07/26/note6/" rel="prev" title="《并发编程实战》笔记">
      <i class="fa fa-chevron-left"></i> 《并发编程实战》笔记
    </a></div>
      <div class="post-nav-item">
    <a href="/2020/07/26/note8/" rel="next" title="小技巧：Typera如何设置高亮和自定义快捷键？">
      小技巧：Typera如何设置高亮和自定义快捷键？ <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          
    <div class="comments" id="valine-comments"></div>

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#参考博客"><span class="nav-number">1.</span> <span class="nav-text">参考博客</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#获取指定时间的上一个工作日和下一个工作日（无判断节假日，调休）"><span class="nav-number">2.</span> <span class="nav-text">获取指定时间的上一个工作日和下一个工作日（无判断节假日，调休）</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#LocalDate、LocalTime、LocalDateTime-三者区别"><span class="nav-number">3.</span> <span class="nav-text">LocalDate、LocalTime、LocalDateTime 三者区别</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#时间戳"><span class="nav-number">3.1.</span> <span class="nav-text">时间戳</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#Instant"><span class="nav-number">3.1.1.</span> <span class="nav-text">Instant</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Duration"><span class="nav-number">3.1.2.</span> <span class="nav-text">Duration</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Period"><span class="nav-number">3.1.3.</span> <span class="nav-text">Period</span></a></li></ol></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#问题1：错误"><span class="nav-number">4.</span> <span class="nav-text">问题1：错误</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#问题2：-学习jdk1-8-的时间"><span class="nav-number">5.</span> <span class="nav-text">问题2： 学习jdk1.8 的时间</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#问题3-关于js端口的时间格式化问题"><span class="nav-number">6.</span> <span class="nav-text">问题3: 关于js端口的时间格式化问题</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#问题4：-时间比较的问题"><span class="nav-number">7.</span> <span class="nav-text">问题4： 时间比较的问题</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#问题5：调用format出现Text-39-2020-06-02-15-22-22-39-could-not-be-parsed-unparsed-text-found-at-index-10"><span class="nav-number">8.</span> <span class="nav-text">问题5：调用format出现Text &#39;2020-06-02 15:22:22&#39; could not be parsed, unparsed text found at index 10</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#问题6：关于DateTimeParseException"><span class="nav-number">9.</span> <span class="nav-text">问题6：关于DateTimeParseException</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#其他问题收集"><span class="nav-number">10.</span> <span class="nav-text">其他问题收集</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#关于LocalDate-class的一个坑"><span class="nav-number">10.1.</span> <span class="nav-text">关于LocalDate.class的一个坑</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#格式化问题"><span class="nav-number">10.2.</span> <span class="nav-text">格式化问题:</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#侠说java8-LocalDateTime等时间使用手册（全）"><span class="nav-number">11.</span> <span class="nav-text">侠说java8-LocalDateTime等时间使用手册（全）</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#源码个人解读"><span class="nav-number">12.</span> <span class="nav-text">源码个人解读</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#TemporalAccessor"><span class="nav-number">12.1.</span> <span class="nav-text">TemporalAccessor</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#接口方法：isSupported"><span class="nav-number">12.1.1.</span> <span class="nav-text">接口方法：isSupported()</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#接口方法：range-TemporalField-field"><span class="nav-number">12.1.2.</span> <span class="nav-text">接口方法：range(TemporalField field)</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#接口方法：int-get-TemporalField-field"><span class="nav-number">12.1.3.</span> <span class="nav-text">接口方法：int get(TemporalField field)</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#接口方法：default-R-query-TemporalQuery-query"><span class="nav-number">12.1.4.</span> <span class="nav-text">接口方法：default  R query(TemporalQuery query)</span></a></li></ol></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">阿东</p>
  <div class="site-description" itemprop="description">随遇而安</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">239</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">36</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">37</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <span class="exturl" data-url="aHR0cHM6Ly9naXRodWIuY29tL2xhenlUaW1lcw==" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;lazyTimes"><i class="fa fa-fw fa-github"></i>GitHub</span>
      </span>
      <span class="links-of-author-item">
        <span class="exturl" data-url="bWFpbHRvOjEwOTc0ODM1MDhAcXEuY29t" title="E-Mail → mailto:1097483508@qq.com"><i class="fa fa-fw fa-envelope"></i>E-Mail</span>
      </span>
  </div>


  <div class="links-of-blogroll motion-element">
    <div class="links-of-blogroll-title">
      <i class="fa fa-fw fa-link"></i>
      友情链接
    </div>
    <ul class="links-of-blogroll-list">
        <li class="links-of-blogroll-item">
          <span class="exturl" data-url="aHR0cHM6Ly93d3cuNTJwb2ppZS5jbi9ob21lLnBocD9tb2Q9c3BhY2UmdWlkPTE0OTc3MTgmZG89dGhyZWFkJnZpZXc9bWUmZnJvbT1zcGFjZQ==" title="https:&#x2F;&#x2F;www.52pojie.cn&#x2F;home.php?mod&#x3D;space&amp;uid&#x3D;1497718&amp;do&#x3D;thread&amp;view&#x3D;me&amp;from&#x3D;space">吾爱破解</span>
        </li>
        <li class="links-of-blogroll-item">
          <span class="exturl" data-url="aHR0cHM6Ly9qdWVqaW4uaW0vdXNlci8yOTk5MTIzNDUyNjI2MzY2" title="https:&#x2F;&#x2F;juejin.im&#x2F;user&#x2F;2999123452626366">掘金</span>
        </li>
        <li class="links-of-blogroll-item">
          <span class="exturl" data-url="aHR0cHM6Ly9zZWdtZW50ZmF1bHQuY29tL3UvbGF6eXRpbWVz" title="https:&#x2F;&#x2F;segmentfault.com&#x2F;u&#x2F;lazytimes">思否</span>
        </li>
    </ul>
  </div>

      </div>

      <div class="wechat_OA">
        <span>欢迎关注我的公众号</span>
        <br>
          <!-- 这里添加你的二维码图片 -->
        <img src ="https://adong-picture.oss-cn-shenzhen.aliyuncs.com/adong/wechat_channel.jpg">
      </div>
        <div class="back-to-top motion-element">
          <i class="fa fa-arrow-up"></i>
          <span>0%</span>
        </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2023</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">阿东</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
      <span class="post-meta-item-text">站点总字数：</span>
    <span title="站点总字数">2m</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
      <span class="post-meta-item-text">站点阅读时长 &asymp;</span>
    <span title="站点阅读时长">29:50</span>
</div>
  <div class="powered-by">由 <span class="exturl theme-link" data-url="aHR0cHM6Ly9oZXhvLmlv">Hexo</span> & <span class="exturl theme-link" data-url="aHR0cHM6Ly90aGVtZS1uZXh0Lm9yZw==">NexT.Gemini</span> 强力驱动
  </div>

        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item" id="busuanzi_container_site_uv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item" id="busuanzi_container_site_pv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="//cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js"></script>
  <script src="//cdn.jsdelivr.net/gh/fancyapps/fancybox@3/dist/jquery.fancybox.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>




  




  
<script src="/js/local-search.js"></script>













  

  


<script>
NexT.utils.loadComments(document.querySelector('#valine-comments'), () => {
  NexT.utils.getScript('//unpkg.com/valine/dist/Valine.min.js', () => {
    var GUEST = ['nick', 'mail', 'link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item => {
      return GUEST.includes(item);
    });
    new Valine({
      el         : '#valine-comments',
      verify     : false,
      notify     : true,
      appId      : 'qMUpEEvBgXaMDD1b0ftgi9xr-gzGzoHsz',
      appKey     : 'UCdfT4Rfih6MO6y8DI4fstf6',
      placeholder: "Just go go",
      avatar     : 'mm',
      meta       : guest,
      pageSize   : '10' || 10,
      visitor    : false,
      lang       : 'zh-CN' || 'zh-cn',
      path       : location.pathname,
      recordIP   : false,
      serverURLs : ''
    });
  }, window.Valine);
});
</script>

</body>
</html>
